from machine import Pin
import machine
import utime
from 驱动.mpu6050 import accel

sda = Pin(40)
scl = Pin(41)
i2c = machine.SoftI2C(sda=sda, scl=scl, freq=40000)
 
# 第二个参数为加速度最大量程
# 0 ±2G   1  ±4G
# 2 ±8G   3  ±16G

address=i2c.scan()
print(address)
cgq = accel(i2c, 0)

while True:
    v = cgq.get_values()
   
    acX = round(v['AcX'] / 16384.0,2)
    acY = round(v['AcY'] / 16384.0,2)
    acZ = round(v['AcZ'] / 16384.0,2)
    utime.sleep(0.1)
    print(f"acX:{acX}----acY:{acY}----acZ:{acZ}")
 

    #print(v)  # {'GyZ': -83, 'GyY': 532, 'GyX': -484, 'Tmp': 28.05941, 'AcZ': 17272, 'AcY': -104, 'AcX': 608}
    


